package cn.com.utt.common.message;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;

public class Download extends Message {
	@JSONField(name = "replyto")
	private String replyTo;
	@JSONField(name = "filetype")
	private int fileType;
	@JSONField(name = "url")
	private String URL;
	@JSONField(name = "version")
	private String softVersion;
	@JSONField(name = "filename")
	private String filename;
	@JSONField(name = "filesize")
	private int fileSize;
	@JSONField(name = "md5")
	private String MD5;
	@JSONField(name = "delay")
	private int delay;
	@JSONField(name = "method")
	private String method;

	public Download() {
		setType(MessageType.DOWNLOAD.toString());
	}
	
	@Override
	public String encode() {
		return JSON.toJSONString(this);
	}

	@Override
	public void decode(byte[] buf) {
		Download download = JSON.parseObject(buf, Download.class);
		this.setId(download.getId());
		this.replyTo = download.getReplyTo();
		this.fileType = download.getFileType();
		this.URL = download.getURL();
		this.softVersion = download.getSoftVersion();
		this.filename = download.getFilename();
		this.fileSize = download.getFileSize();
		this.MD5 = download.getMD5();
		this.delay = download.getDelay();
		this.method = download.getMethod();
	}

	public String getReplyTo() {
		return replyTo;
	}

	public void setReplyTo(String replyTo) {
		this.replyTo = replyTo;
	}

	public int getFileType() {
		return fileType;
	}

	public void setFileType(int fileType) {
		this.fileType = fileType;
	}

	public String getURL() {
		return URL;
	}

	public void setURL(String URL) {
		this.URL = URL;
	}

	public String getSoftVersion() {
		return softVersion;
	}

	public void setSoftVersion(String softVersion) {
		this.softVersion = softVersion;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public int getFileSize() {
		return fileSize;
	}

	public void setFileSize(int fileSize) {
		this.fileSize = fileSize;
	}

	public String getMD5() {
		return MD5;
	}

	public void setMD5(String mD5) {
		MD5 = mD5;
	}

	public int getDelay() {
		return delay;
	}

	public void setDelay(int delay) {
		this.delay = delay;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

}
